# coding=utf-8
numb1, numb2 = 1, 2


# while numb1 < 3:
#     print(numb1)
#     numb1 += 1
# else:
#     print(numb2)
# for一般用来遍历 循环还是用while多一些类似ruby
# for i in "qwertyuiop":
#     print(i)
# 函数传递的参数类型如果是可变类型则会影响函数外部的变量
# list = [1,2,3]
# def test(num,lis):
#     num += 1
#     lis[0]=55
#     print(num,lis)
#
# test(numb1,list)
# print(numb1,list[0])
# 测试关键字参数传递
# def tset(num,strs):
#     print("strs = ",strs,"num = ",num)
#
# strs = "asdfadsf"
# num = 12312
# tset(strs,num)
# 作用域的问题 global调用全局变量之后就不能在生成同名变量了 nonlocal调用嵌套上一级的变量
# def test1():
#     global numb1
#     print(numb1)
#     numb1 = 2
#     nnm = 4
#     def test2():
#         nonlocal nnm
#         print(nnm)
#     test2()
# test1()
# print(numb1)

# def fact_iter(num,product):
#     if num == 1:
#         return product
#     return fact_iter(num-1,num*product)
#
# def fact(n):
#     return fact_iter(n,1)
#
# print(fact(100))

# def triange(mix):
#     n = 0
#     l = [1]
#     while n < mix:
#         yield l
#         l = [l[x]+l[x+1] for x in range(len(l)-1)]
#         l.insert(0,1)
#         l.append(1)
#         n+=1
# a = triange(10)
# for i in a:
#     print(i)

# 凡是可作用于for循环的对象都是Iterable类型；
# 凡是可作用于next()函数的对象都是Iterator类型
# a = [1,2,3,4]
# b = iter(a)  #转换成Iterator类型
# print(next(b))

# def _odd_iter():
#     n = 1
#     while True:
#         n = n + 2
#         yield n
#
#
# def _not_divisible(n):
#     return lambda x: x % n > 0
#
#
# def primes():
#     yield 2
#     it = _odd_iter()
#     while True:
#         n = next(it)
#         yield n
#         it = filter(_not_divisible(n), it)
#
#
# for n in primes():
#     if n < 1000:
#         print(n)
#     else:
#         break

def lazy_sum(*args):
    def sum():
        ax=0
        for n in args:
            ax=ax+n
        return ax
    return sum

f = lazy_sum(1,2,3,4)
print(f())